package org.tnaggs.project.manager;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.tnaggs.project.model.Game;
import org.tnaggs.project.model.Location;
import org.tnaggs.project.repository.ContactRepository;
import org.tnaggs.project.repository.ConversionRepository;
import org.tnaggs.project.repository.GameRepository;
import org.tnaggs.project.repository.LocationRepository;

public class GameManager {

	@Autowired
	private LocationRepository localRepo;
	
	@Autowired
	private GameRepository gameRepo;
	
	@Autowired
	private ContactRepository contactRepo;
	
	@Autowired
	private ConversionRepository conversionRepo;
	
	public List<Location> getAllLocations() {
		return localRepo.findAll();
	}
	
	public void createGame(Game newVal) {
		gameRepo.insert(newVal);
	}
	
	public List<Game> getAllGames() {
		return gameRepo.findAll();
	}
	
	public List<Game> getGamesByLocationID(int localID) {
		return gameRepo.findByLocalID(localID);
	}
	
	public List<Game> getAllGamesByTeam(long teamID) {
		return gameRepo.findByTeamID(teamID);
	}

	public ContactRepository getContactRepo() {
		return contactRepo;
	}

	public void setContactRepo(ContactRepository contactRepo) {
		this.contactRepo = contactRepo;
	}

	public LocationRepository getLocalRepo() {
		return localRepo;
	}

	public void setLocalRepo(LocationRepository localRepo) {
		this.localRepo = localRepo;
	}

	public GameRepository getGameRepo() {
		return gameRepo;
	}

	public void setGameRepo(GameRepository gameRepo) {
		this.gameRepo = gameRepo;
	}

	public ConversionRepository getConversionRepo() {
		return conversionRepo;
	}

	public void setConversionRepo(ConversionRepository conversionRepo) {
		this.conversionRepo = conversionRepo;
	}

	public void updateScore(int gameID, int homeScore, int awayScore) {
		gameRepo.updateScore(gameID,homeScore,awayScore);
	}
	
	
	
	
}
